﻿var  errorCode= {
    "Success": "操作成功",
    "UserAlreadyExits": "用户已存在",
    "UserNotActivate":"用户尚未激活",
    "EmailOrTelphoneRequired": "请输入邮件地址或手机号码",
    "EmailRequired": "邮件是必填项",
    "TelPhoneRequired": "手机号码是必填项",
    "TelPhoneLegthError": "手机号码格式错误",
    "TelPhoneAlreadyExists":"手机号码已注册",
    "EmailFormatError": "邮件格式错误",
    "PasswordLengthError": "密码长度必须大于8位并小于22位",
    "ConfirmPasswordNotMath": "两次密码输入不一致",
    "PasswordNotMatch": "密码错误",
    "SMSSendTooMany":"请勿重复发送短信",
    "SMSError": "发送短信验证码失败",
    "SMSCodeNotFoundOrExpird": "短信验证码无效或过期",
    "PasswordErrorRemainTry": "密码错误,余下剩余次数",
    "UserNotFound": "用户不存在",
    "ScreenLocked": "屏幕已锁定",
    "ScreenUnlock": "屏幕未锁定",
    "ValidateCodeFalied": "验证码错误",
    "PasswordLockout": "账号已经锁定",
    "DoNotRepeatSendMail": "请勿频发发送邮件",
    "UserAlreadyConfirmEmail": "邮件已经确定",
    "BalanceNotEnough": "余额不足",
    "NotEnoughCash": "现金余额不足",
    "NotEnoughCoin": "币余额不足",
    "AdvancedpasswordNotMatch": "二级密码错误",
    "SuccessChangePassword": "密码修改成功",
    "ChangePasswordFailed": "密码修改失败，请联系管理员",
    "LinkOutOfTime": "链接已失效",
    "IdentifyMustTakeTwoPic": "请上传身份证正反面",
    "ModelNotMatch": "请检查你的提交的表单",
    "ChargeSuccess": "充值成功",
    "OrderNotFound": "订单不存在",
    "HandlerObjectCanNotBeSamePerson": "操作对象不能为自己",
    "ProcedureExceptionAndRollback": "数据库异常",
    "SecurityWarnning": "安全异常!请联系管理员!",
    "GoogleCodeCanNotFound":"Google验证码不存在!",
    "Failed": "操作失败",
    "Exception":"系统异常",
    "Default": "发送请求失败！服务器无响应！",
    "nameNotNull":"激励计划名称不能为空！",
    "pointError":"必须为数字，并且不可超过2位小数！",
    "pointNotNull":"积点名称不能为空！",
};

function getDescript(key)
{
    if (errorCode != null && errorCode[key] != null) {
        return errorCode[key];
    } else {
        return errorCode["Default"];
    }
}

var RegArray = {
    Require: /.+/,
    Email: /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/,
    Phone: /^((\(\d{2,3}\))|(\d{3}\-))?(\(0\d{2,3}\)|0\d{2,3}-)?[1-9]\d{6,7}(\-\d{1,4})?$/,
    Mobile: /^(0|86|17951)?(13[0-9]|15[012356789]|17[678]|18[0-9]|14[57])[0-9]{8}$/,
    Url: /^http:\/\/[A-Za-z0-9]+\.[A-Za-z0-9]+[\/=\?%\-&_~`@[\]\':+!]*([^<>\"\"])*$/,
    Currency: /^\d+(\.\d+)?$/,
    Number: /^\d+$/,
    Zip: /^[1-9]\d{5}$/,
    QQ: /^[1-9]\d{4,8}$/,
    Integer: /^[-\+]?\d+$/,
    Double: /^[-\+]?\d+(\.\d+)?$/,
    English: /^[A-Za-z]+$/,
    Chinese: /^[\u0391-\uFFE5]+$/,
    Username: /^[a-z]\w{3,}$/i,
    Password: /^[\@A-Za-z0-9\!_\#\$\%\^\&\*\.\~]{8,22}$/,
    UnSafe: /^(([A-Z]*|[a-z]*|\d*|[-_\~!@#\$%\^&\*\.\(\)\[\]\{\}<>\?\\\/\'\"]*)|.{0,5})$|\s/,
    Ip: /^(([1-9]|([1-9]\d)|(1\d\d)|(2([0-4]\d|5[0-5])))\.)(([1-9]|([1-9]\d)|(1\d\d)|(2([0-4]\d|5[0-5])))\.){2}([1-9]|([1-9]\d)|(1\d\d)|(2([0-4]\d|5[0-5])))$/,
    IDCard: /^(\d{15}$|^\d{18}$|^\d{17}(\d|X|x))$/,
}

function ValidateValue(value, check) {

    var reg;
    if (check == 'Require') {
        reg = RegArray.Require;
    } else if (check == "Email") {
        reg = RegArray.Email;
    } else if (check == "Phone") {
        reg = RegArray.Phone;
    } else if (check == "Mobile") {
        reg = RegArray.Mobile;
    } else if (check == "Url") {
        reg = RegArray.Url;
    } else if (check == "Currency") {
        reg = RegArray.Currency;
    } else if (check == "Number") {
        reg = RegArray.Number;
    } else if (check == "Zip") {
        reg = RegArray.Zip;
    } else if (check == "QQ") {
        reg = RegArray.QQ;
    } else if (check == "Integer") {
        reg = RegArray.Integer;
    } else if (check == "Double") {
        reg = RegArray.Double;
    } else if (check == "English") {
        reg = RegArray.English;
    } else if (check == "Chinese") {
        reg = RegArray.Chinese;
    } else if (check == "Username") {
        reg = RegArray.Username;
    } else if (check == "Password") {
        reg = RegArray.Password;
    } else if (check == "UnSafe") {
        reg = RegArray.UnSafe;
    } else if (check == "Ip") {
        reg = RegArray.Ip;
    } else if (check == "IDCard") {
        reg = RegArray.IDCard;
    }
    return reg.test(value);
}

function showAlertBox(id, text) {
    var newid = $("#" + id);
    if (text != "") {
        newid.text(text);
    }
    newid.fadeIn();
    setTimeout(function () {
        newid.fadeOut(1000)
    }, 5000);
}